דלג לתוכן הראשי

better_messages_before_new_thread

פעולה זו מאפשרת למנוע התחלת שיחה חדשה בהתבסס על תנאים מותאמים אישית.

add_action( 'better_messages_before_new_thread', 'custom_restrict_new_thread', 10, 2);
function custom_restrict_new_thread( &$args, &$errors ){
// משתמש שיוצר שיחה
$user_id = get_current_user_id();

// קבל מערך עם מזהי משתמש של נמענים, שאיתו משתמש מנסה להתחיל שיחה
$recipients = $args['recipients'];

/**
* ההיגיון שלך לקבוע אם משתמש זה יכול ליצור שרשור
*/
$can_create_thread = false;


if( ! $can_create_thread ){
/**
* הוספת שגיאה שתוצג למשתמש
*/
$errors['uniqueErrorSlug'] = 'You cant start new thread now.';
}
}

alt text